package chapter13;

public class TestGeometricObject {
  /** Main method */
  public static void main(String[] args) {
    // Declare and initialize two geometric objects 声明并初始化两个几何对象
    GeometricObject geoObject1 = new Circle(5);
    GeometricObject geoObject2 = new Rectangle(5, 3);
    GeometricObject geoObject3 = new Triangle(3, 4, 5);


    System.out.println("Which of these three objects is the largest?" + //这三个物体哪个最大？
      maxarea(geoObject1, geoObject2 , geoObject3));

    // Display circle 显示矩形
    displayGeometricObject(geoObject1);

    // Display rectangle
    displayGeometricObject(geoObject2);

    // Display rectangle
    displayGeometricObject(geoObject3);

    GeometricObject maxAreaObject=maxarea(geoObject1,geoObject2,geoObject3);
  }

  /** A method for comparing the areas of three geometric objects  比较三个几何物体面积的方法 */
  public static GeometricObject maxarea(GeometricObject object1,
      GeometricObject object2,GeometricObject object3) {

    GeometricObject result;
    if(object1.getArea()>object2.getArea()) result=object1;
    else result=object2;

    if(result.getArea()< object3.getArea()) result=object3;

    return result;

    //return object1.getArea() == object2.getArea();

  }

  /** A method for displaying a geometric object  一种显示几何对象的方法 */
  public static void displayGeometricObject(GeometricObject object) {
    System.out.println();
    System.out.println("The area is " + object.getArea());
    System.out.println("The perimeter is" + object.getPerimeter());
  }
}
